package com.citic.netty.client.console;

import java.util.Scanner;

import com.citic.netty.common.protocol.request.LoginRequestPacket;

import io.netty.channel.Channel;

public class LoginConsoleCommand implements ConsoleCommand {

	@Override
	public void exec(Scanner scanner, Channel channel) {
        System.out.print("输入用户名登录: ");
        
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        loginRequestPacket.setUsername(scanner.nextLine());
        loginRequestPacket.setPassword("pwd");

        channel.writeAndFlush(loginRequestPacket);
        waitForLoginResponse();		
	}

	private void waitForLoginResponse() {
		try {
            Thread.sleep(1000);
        } catch (InterruptedException ignored) {
        	
        }		
	}
}
